| Conditions | 2 |
| Total Lines | 72 |
| Code Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 3 |
| CRAP Score | 2 |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import { DataSource } from 'typeorm'; |
||
| 5 | async run(connection: DataSource): Promise<void> { |
||
| 6 | 9 | if (true) {//process.env.NODE_ENV !== 'production') { |
|
|
|
|||
| 7 | 9 | const userRepo = connection.getRepository(User); |
|
| 8 | |||
| 9 | // Add example admin and test users |
||
| 10 | 9 | await userRepo.save([ |
|
| 11 | { |
||
| 12 | githubId: '149484382', |
||
| 13 | username: 'Pbris', |
||
| 14 | email: '[email protected]', |
||
| 15 | roles: ['admin'], |
||
| 16 | hasAcceptedTerms: true, |
||
| 17 | isMonthlyPayment: false, |
||
| 18 | accumulatedCost: 0, |
||
| 19 | balance: 100, |
||
| 20 | }, |
||
| 21 | { |
||
| 22 | githubId: '149296874', |
||
| 23 | username: 'airhelios', |
||
| 24 | email: '[email protected]', |
||
| 25 | roles: ['admin'], |
||
| 26 | hasAcceptedTerms: true, |
||
| 27 | isMonthlyPayment: true, |
||
| 28 | accumulatedCost: 0, |
||
| 29 | }, |
||
| 30 | { |
||
| 31 | githubId: '13668660', |
||
| 32 | username: 'KarlComSe', |
||
| 33 | email: '[email protected]', |
||
| 34 | roles: ['admin'], |
||
| 35 | hasAcceptedTerms: true, |
||
| 36 | isMonthlyPayment: true, |
||
| 37 | accumulatedCost: 0, |
||
| 38 | }, |
||
| 39 | { |
||
| 40 | githubId: '149683406', |
||
| 41 | username: 'gumme1', |
||
| 42 | email: '[email protected]', |
||
| 43 | roles: ['admin'], |
||
| 44 | hasAcceptedTerms: true, |
||
| 45 | isMonthlyPayment: true, |
||
| 46 | accumulatedCost: 0, |
||
| 47 | }, |
||
| 48 | { |
||
| 49 | githubId: '123456789', |
||
| 50 | username: 'johndoe', |
||
| 51 | email: '[email protected]', |
||
| 52 | roles: ['user'], |
||
| 53 | hasAcceptedTerms: true, |
||
| 54 | avatarUrl: 'https://example.com/john.jpg', |
||
| 55 | isMonthlyPayment: true, |
||
| 56 | accumulatedCost: 0, |
||
| 57 | }, |
||
| 58 | { |
||
| 59 | githubId: '234567890', |
||
| 60 | username: 'janedoe', |
||
| 61 | email: '[email protected]', |
||
| 62 | roles: ['user', 'admin'], |
||
| 63 | hasAcceptedTerms: true, |
||
| 64 | avatarUrl: 'https://example.com/jane.jpg', |
||
| 65 | isMonthlyPayment: true, |
||
| 66 | accumulatedCost: 0, |
||
| 67 | }, |
||
| 68 | { |
||
| 69 | githubId: '345678901', |
||
| 70 | username: 'bobsmith', |
||
| 71 | email: '[email protected]', |
||
| 72 | roles: ['user'], |
||
| 73 | hasAcceptedTerms: false, |
||
| 74 | avatarUrl: 'https://example.com/bob.jpg', |
||
| 75 | isMonthlyPayment: true, |
||
| 76 | accumulatedCost: 0, |
||
| 77 | }, |
||
| 82 |